﻿using System.Windows;

namespace Gmantis.Controls.Chart
{
    public class BarColumnOptions : DependencyObject
    {
        // Fields
        public static DependencyProperty OriginProperty = Utils.RegisterAttachedProperty("Origin", typeof(double), typeof(BarColumnOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), 0.0);
        public static readonly DependencyProperty RadiusXProperty = Utils.RegisterAttachedProperty("RadiusX", typeof(double), typeof(BarColumnOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), 0.0);
        public static DependencyProperty RadiusYProperty = Utils.RegisterAttachedProperty("RadiusY", typeof(double), typeof(BarColumnOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), 0.0);
        public static readonly DependencyProperty SeriesOverlapProperty = DependencyProperty.RegisterAttached("SeriesOverlap", typeof(double), typeof(BarColumnOptions), new PropertyMetadata(0.0, new PropertyChangedCallback(Chart.OnAttachedPropertyChanged)));
        public static DependencyProperty SizeProperty = Utils.RegisterAttachedProperty("Size", typeof(double), typeof(BarColumnOptions), new PropertyChangedCallback(Chart.OnAttachedPropertyChanged), 0.7);
        public static readonly DependencyProperty StackGroupProperty = DependencyProperty.RegisterAttached("StackGroup", typeof(int), typeof(BarColumnOptions), new PropertyMetadata(0));

        // Methods
        [AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetOrigin(Chart chart)
        {
            return (double)chart.GetValue(OriginProperty);
        }

        [AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetRadiusX(Chart chart)
        {
            return (double)chart.GetValue(RadiusXProperty);
        }

        [AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetRadiusY(Chart chart)
        {
            return (double)chart.GetValue(RadiusYProperty);
        }

        [AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetSeriesOverlap(Chart chart)
        {
            return (double)chart.GetValue(SeriesOverlapProperty);
        }

        [AttachedPropertyBrowsableForType(typeof(Chart))]
        public static double GetSize(Chart chart)
        {
            return (double)chart.GetValue(SizeProperty);
        }

        [AttachedPropertyBrowsableForType(typeof(DataSeries))]
        public static int GetStackGroup(DataSeries ds)
        {
            return (int)ds.GetValue(StackGroupProperty);
        }

        internal static void Reset(Chart chart)
        {
            chart.ClearValue(OriginProperty);
            chart.ClearValue(RadiusXProperty);
            chart.ClearValue(RadiusYProperty);
            chart.ClearValue(SizeProperty);
            chart.ClearValue(SeriesOverlapProperty);
        }

        public static void SetOrigin(Chart chart, double value)
        {
            chart.SetValue(OriginProperty, value);
        }

        public static void SetRadiusX(Chart chart, double value)
        {
            chart.SetValue(RadiusXProperty, value);
        }

        public static void SetRadiusY(Chart chart, double value)
        {
            chart.SetValue(RadiusYProperty, value);
        }

        public static void SetSeriesOverlap(Chart chart, double value)
        {
            chart.SetValue(SeriesOverlapProperty, value);
        }

        public static void SetSize(Chart chart, double value)
        {
            chart.SetValue(SizeProperty, value);
        }

        public static void SetStackGroup(DataSeries ds, int value)
        {
            ds.SetValue(StackGroupProperty, value);
        }
    }
}
